package com.music.controller;

import com.music.pojo.Copyright;
import com.music.service.CopyrightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class CopyrightController {
    @Autowired
    private CopyrightService copyrightService;

    @RequestMapping("/findAllCopyright")
    @ResponseBody
    public List<Copyright> findAllCopyright(){
        List<Copyright> list=copyrightService.findAllCopyright();
        return list;
    }

    @RequestMapping("/findInfoSongCopyright")
    @ResponseBody
    public List<Copyright> findInfoSongCopyrigh(){
        int song_id=1;
        List<Copyright> list=copyrightService.findInfoSongCopyright(1);
        return list;
    }

    @RequestMapping("/findInfoSingerCopyright")
    @ResponseBody
    public List<Copyright> findInfoSingerCopyrigh(){
        int singer_id=1;
        List<Copyright> list=copyrightService.findInfoSingerCopyright(1);
        return list;
    }

    @RequestMapping("/addCopyright")
    @ResponseBody
    public Map<Object,Object> addCopyright(){
        Map<Object,Object> result=new HashMap();
        Copyright copyright=new Copyright();
        copyright.setSong_id(2);
        copyright.setSinger_id(2);
        copyright.setIsright(1);
        boolean flag=copyrightService.addCopyright(copyright);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }
    @RequestMapping("/deleteCopyright")
    @ResponseBody
    public Map<Object,Object> deleteCopyright(){
        Map<Object,Object> result=new HashMap();
       int[] ids={1,2};
        boolean flag=copyrightService.deleteCopyright(ids);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }
    @RequestMapping("/updateCopyright")
    @ResponseBody
    public Map<Object,Object> updateCopyright(){
        Map<Object,Object> result=new HashMap();
        Copyright copyright=new Copyright();
        copyright.setId(1);
        copyright.setSong_id(3);
        copyright.setSinger_id(3);
        copyright.setIsright(1);
        boolean flag=copyrightService.updateCopyright(copyright);
        if(flag) {
            result.put("status", "200");
            result.put("msg", "success");
        }
        return result;
    }
}
